package us.gaaoc.framework.model.constants;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.faces.application.Application;
import javax.faces.context.FacesContext;


public class Constants {
		
	

	
	public class Courts 
	{
		public static final String ChathamCounty = "courtUuidChatham";
		public static final String JeffersonCounty = "courtUuidJefferson";
		public static final String FultonCounty = "courtUuid4";
		public static final String BibbCounty = "courtUuidBibb";
		public static final String WashingtonCounty = "courtUuid2";
		public static final String OglethorpeCounty = "courtUuidOglethorpe";
		public static final String ClarkeCounty = "courtUuidClarke";
		public static final String HoustonCounty = "courtUuidHouston";
		public static final String CowetaCounty = "courtUuidCoweta";
		public static final String BaldwinCounty = "courtUuidBaldwin";
		public static final String BullochCounty = "courtUuidBulloch";
		public static final String Jenkins = "courtUuidJenkins";
		public static final String PeachCounty = "courtUuidPeach";
	}

	public class ParticipantRelationship
	{
		public static final int InitiatingParty = 1;
		public static final int DefendantParty = 2;
		public static final int Witness = 3;
		public static final int ProsecutionAttorney = 4;
		public static final int DefendantAttorney = 5;
		public static final int Filer = 6;
		
	}
	
	/*
	 * Vim regular expressions.
	 * %s, ,_,g
	 * %s,-,_,g
	 * s,\([a-z]\)\([A-Z]\),\1_\2,g
	 * %!tr '[a-z]' '[A-Z]'
	 * %s:.*(\(\d\+\),_'\([a-zA-Z_ -]\+\)'.*:public static final int \2 = \1;:g
	 */
	
	public class CaseRecordStatus
	{
		public static final int RECEIVED = 1;
		public static final int IMPORTED = 2;
		public static final int REJECTED = 3;
		public static final int SERVED = 4;
		public static final int NON_SERVED = 5;
		public static final int DISPOSED = 6;
		public static final int UNSENT = 7;
		public static final int REJECTED_BY_ATTORNEY = 8;
		public static final int ACCEPTED_BY_ATTORNEY = 9;
		public static final int RECEIVED_BY_ATTORNEY = 10;
		public static final int READY_TO_SEND_TO_COURT = 11;
		public static final int FILED = 12;
		public static final int RECEIVED_BY_JUDGE = 13;
		/*_CHANGE_"RECEIVED"_STATUS_TO_"RECEIVEDBYCLERK"*/
		public static final int RECEIVED_BY_CLERK = 14;

		/*_STATUS_TO_UPDATE_EXISTING_CASE_*/
		public static final int UNSENT_ADDITION = 15;
		public static final int SENT_TO_ATTORNEY_ADDITION = 16;
		/*_AFTER_JUDGE_SIGNED_THE_DOCUMENT,_DOCUMENT_IS_READY_TO_DISPOSE_*/
		public static final int READY_TO_DISPOSE = 17;
		/*_AFTER_JUDGE_SIGNED_AND_SENT_TO_CLERK_*/
		public static final int RECEIVED_FROM_JUDGE = 18;
		/*_AFTER_JUDGE_REJECTS_*/
		public static final int REJECTED_BY_JUDGE = 19;
		/*_AFTER_CLERK_REVIEWS_AND_SIGNS_*/ 
		public static final int READY_TO_IMPORT = 20;
		public static final int QUEUED_FOR_IMPORT = 21;
		public static final int FAILED_TO_IMPORT = 22;

	}
	
	/**
	 * TODO: We have many duplicates in here!
	 */
	public static class DocumentType
	{
		public static final int OF_SERVICE_1 = 1;
		public static final int SUPPORT_OF_RULE_ABSOLUTE = 2;
		public static final int AGENCY = 3;
		public static final int TEST_RESULTS = 4;
		public static final int WORKSHEET = 5;
		public static final int PATERNITY_STATEMENT = 6;
		public static final int OF_SERVICE_7 = 7;
		public static final int PETITION = 8;
		public static final int CONTEMPT_COMPLAINT = 9;
		public static final int FORM_DISPOSITION = 10;
		public static final int FORM_INITIATION = 11;
		public static final int INITIAL = 12;
		public static final int TO_CLOSE_CASE = 13;
		public static final int TO_TRANSFER_14 = 14;
		public static final int TO_VACATE = 15;
		public static final int ADD_PARTY = 16;
		public static final int CONTEMPT_MOTION = 17;
		public static final int CORRECT_CLERICAL_ERROR = 18;
		public static final int TO_PRODUCE = 19;
		public static final int OF_HEARING = 20;
		public static final int ADDING_PARTY = 21;
		public static final int CONTEMPT_ORDER = 22;
		public static final int FINAL = 23;
		public static final int INCOME_DEDUCTION = 24;
		public static final int PATERNITY_TESTING = 25;
		public static final int RULE_ABSOLUTE = 26;
		public static final int RULE_NISI = 27;
		public static final int SUPPORT = 28;
		public static final int TEMPORARY = 29;
		public static final int TO_CORRECT_CLERICAL_ERROR = 30;
		public static final int TRANSFER = 31;
		public static final int REVIEW_MODIFICATION = 32;
		public static final int SUBPOENA = 33;
		public static final int JUDICIAL_SUMMONS = 34;
		public static final int ADOPT_AGENCY_RECOMMENDATION = 35;
		public static final int RECOVERY_OF_CHILD_SUPPORT = 36;
		public static final int ADMISSIONS = 37;
		public static final int TEXT_TYPE = 38;
		public static final int CONSENT = 39;
		public static final int OF_DEFAULT = 40;
		public static final int TO_REDIRECT = 41;
		public static final int TO_TRANSFER = 42;
		public static final int OF_REGISTRATION = 43;
		public static final int OF_DNA_TESTING = 44;
		public static final int VOLUNTARY = 45;
		public static final int OF_SERVICE_46 = 46;
		public static final int OF_SERVICE_47 = 47;
	
	}


	public static class CourtEventsExtendedType {
		public static final int CourtRoom = 1;
		
	}
	

		 // "cache" holding all public fields by it's field name: 
		private static Map nameToValueMap = new java.util.HashMap();

		
		static {
			nameToValueMap.put("DocumentCategory",createNameToValueMap(DocumentCategory.class));
			nameToValueMap.put("DocumentType",createNameToValueMap(DocumentType.class));
			
		}
		
		/**
		 * * Puts all public static fields into the resulting Map. * Uses the name
		 * of the field as key to reference it's in the Map. * * @return a Map of
		 * field names to field values of * all public static fields of this class
		 */
		private static Map createNameToValueMap(Class c) {
			Map result = new HashMap();
			Field[] publicFields = c.getFields();
			for (int i = 0; i < publicFields.length; i++) {
				Field field = publicFields[i];
				String name = field.getName();
				try {
					result.put(name, field.get(null));
				} catch (Exception e) {
					System.err.println("Initialization of Constants class failed!");
					e.printStackTrace(System.err);
				}
			}
			return result;
		}
	
		public static Map getNameToValueMap() { return nameToValueMap; } 
			
		
	
	
	public static class DocumentCategory
	{
		public static final int ACKNOWLEDGEMENT = 1;
		public static final int AFFIDAVIT = 2;
		public static final int RECOMMENDATION = 3;
		public static final int SUPPORTING_DOCUMENTATION = 4;
		public static final int CERTIFICATE = 5;
		public static final int COMPLAINT = 6;
		public static final int DISPOSITION = 7;
		public static final int INITIATION = 8; 
		public static final int REQUEST = 9;
		public static final int MOTION = 10;
		public static final int NOTICE = 11;
		public static final int ORDER = 12;
		public static final int PETITION = 13;
		public static final int EFILING = 14;
		public static final int WAIVER = 15;
		public static final int DISMISSAL = 16;

	}
	
	
	public class Roles {

		public static final String CLERKID = "uuid2";
		public static final String AGENTID = "uuid5";
		public static final String ATTORNEYID = "uuid6";
		
	}
	
	public class VisualMarkCategory {
		public static final int COURT_DATE_ID = 2;
		public static final int COURT_ROOM_NUMBER = 6;
		public static final int COURT_TIME = 7;
		public static final int COURT_MONTH = 11;
		
	}
	
	public class DocumentStatus {
		public static final int RECEIVED = 1;
		public static final int IMPORTED = 2;
		public static final int ERROR = 3;
		public static final int REJECTED = 4;
		public static final int SEALED = 5;
		public static final int UPLOAD = 6;
		public static final int PREPARED_FOR_IMPORT = 7;
		public static final int SIGNED_BY_CLERK = 8;
		public static final int STAMPED_WITH_COURT_RECEIVED_STAMP = 9;
		public static final int STAMPED_WITH_CIVIL_ACTION_NUMBER_STAMP = 10;
		public static final int SIGNED_BY_ATTORNEY = 11;
		public static final int FAILED_COURT_RECEIVED_STAMP = 12;
		public static final int FAILED_CIVIL_ACTION_NUMBERSTAMP = 13;
		public static final int FAILED_CLERK_SIGNATURE = 14;
		public static final int FAILED_ATTORNEY_SIGNATURE = 15;
		public static final int FAILED_TO_IMPORT = 16;
		public static final int QUEUED_FOR_IMPORT = 16;
			//TODO: QUEUED_FOR_IMPORT AND FAILED_TO_IMPORT can't be the same code.
			// QUEUED FOR IMPORT is for the webservicse
			// FAILED TO IMPORT is for the Fulton XML
	}
	
	public class CaseRecordEventType {
		public static final int FILING_RECEIVED_BY_CLERK = 1;
		public static final int FILING_IMPORTED_TO_CMS = 2;
		public static final int FILING_REJECTED = 3;
		public static final int SERVED = 4;
		public static final int NON_SERVED = 5;
		public static final int FILING_DISPOSED = 6;
		public static final int ERROR = 7;
		public static final int FILING_REJECTED_BY_ATTORNEY = 8;
		public static final int FILING_RECEIVED_BY_ATTORNEY = 9;
		public static final int FILING_SIGNED_BY_ATTORNEY = 10;
		public static final int FILING_RECEIVED_BY_JUDGE = 11;
		public static final int FILING_CREATED_BY_LEGAL_PREPARER = 12;
		public static final int FILING_READIED_FOR_ADDITION = 13;
		public static final int FILING_READY_TO_DISPOSE = 14;
		public static final int FILING_REVIEWED_AND_SIGNED_BY_JUDGE = 15;
		public static final int FILING_REJECTED_BY_JUDGE = 16;
		public static final int FILING_REVIEWED_AND_SIGNED_BY_CLERK = 17;
		public static final int FILING_NOT_ACCEPTED_BY_COURT_DUE_TO_TECHNICAL_ERROR = 18;
		public static final int FILING_NOT_ACCEPTED_BY_COURT_DUE_TO_CLERK_SIGNATURE_FAILURE = 19;
		public static final int FILING_NOT_ACCEPTED_BY_COURT_DUE_TO_MISSING_COURT_RECEIVED_STAMPS = 20;
		public static final int COURT_DATE_RESET_BY_ATTORNEY = 21;
		public static final int COURT_DATE_RESET_BY_CLERK = 22;
		public static final int MISSING_ATTORNEY_SIGNATURE = 23;
		public static final int FILING_QUEUED_FOR_IMPORT_BY_AGENT = 40;
		public static final int COOPERATING_PARTY_MOVED_AS_DEFENDANT = 41;
	}

	public class CourtEventType {
		public static final int COURT_DATE = 1;
		
	}
	
	public class Stamping {
		/**
		 * These are jregexp syntax regular expressions.
		 * The ({NAME}regexp) notation says replace the regexp matched area with the variable NAME.
		 * @author artripa
		 *
		 */
		public class REGEXP {
			public static final String SIGN_DATE = ".his the ({SIGN_DAY}_+) day of ({SIGN_MONTH_YEAR}_+)";
			public static final String COURT_DATE = "the above-named County on";			
		}
		
		/**
		 * These are el-expressions that are parsed and spit out the prose onto the PDF.
		 * @author artripa
		 *
		 */
		public class PROSE {
			public static final String COURT_DATE_PROSE_CLARKE = "the #{courtdate.day} day of #{courtdate.month}, #{courtdate.year} in the Clarke County Superior Courthouse";
		}
		
		
		
	}
	
}
